﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LoRel;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace CoreTest.KeyAndSchema
{
    /// <summary>
    /// Schema -> Key creation tests can be fairly simple, since most of its tested in 
    /// KeyComparisonAndEquality. We pass the test if we generate equal Keys.
    /// </summary>
    [TestClass]
    public class SchemaKeyGeneration : SchemaBaseData{

        [TestMethod]
        public void SchemaKeyGenerationTest() {
            Schema schema = GetSchema();
            List<KeyPairs> list = GetData();
            foreach (KeyPairs pair in list) {

                Key lhs_created = schema.GetKey(pair.LHS_Pos);
                Key rhs_created = schema.GetKey(pair.RHS_Pos);

                Console.WriteLine(pair.Description);
                Console.WriteLine(pair.LHS);
                Console.WriteLine(pair.RHS);
                Console.WriteLine("Generated by Schema from Pos");
                Console.WriteLine(lhs_created);
                Console.WriteLine(rhs_created);
                
                Assert.IsTrue(
                    lhs_created == pair.LHS && rhs_created == pair.RHS,
                    pair.Description );

                Console.WriteLine();
            }
        }
    }
}
